package com.metroinfo.infrastructure;

import java.util.concurrent.ConcurrentHashMap;

import com.metroinfo.infrastructure.keys.BusInfoDataKey;
import com.metroinfo.infrastructure.value.BusLastAppearanceValue;
import com.metroinfo.interfaces.DataStructInterface;

public class BusLastAppearanceData implements DataStructInterface {

	ConcurrentHashMap<BusInfoDataKey, BusLastAppearanceValue> busLastAppearanceData =
		new ConcurrentHashMap<BusInfoDataKey, BusLastAppearanceValue>();
	
	public BusLastAppearanceData(int cnt){
		for(int i=0; i<cnt; i++){
			busLastAppearanceData.put(new BusInfoDataKey(Integer.valueOf(i)), 
					new BusLastAppearanceValue(Integer.valueOf(i), Integer.valueOf(i%50), Integer.valueOf(i)));
		}
	}
	
	@Override
	public Object getValue(Object o) {
		return busLastAppearanceData.get((BusInfoDataKey)o);
	}

	@Override
	public boolean isExists(Object o) {
		return busLastAppearanceData.containsKey((BusInfoDataKey)o);
	}

	@Override
	public boolean refresh() {
		return true;
	}

}
